package cn.tedu.luban.settle.main.consumer;

import cn.tedu.luban.order.protocol.dto.OrderMessageDTO;
import cn.tedu.luban.settle.main.service.SettleService;
import com.tedu.inn.protocol.exception.BusinessException;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(
        topic="order_finish_topic",
        consumerGroup = "settle-group")
public class SettleBillConsumer implements RocketMQListener<OrderMessageDTO> {
    @Autowired
    private SettleService settleService;
    @Override
    public void onMessage(OrderMessageDTO orderMqDTO) {
        try{
            settleService.settle(orderMqDTO);
        }catch (BusinessException e){
            e.printStackTrace();
            return;
        }
    }
}
